package com.tanhua.server.controller;

import com.tanhua.domain.vo.PageResult;
import com.tanhua.domain.vo.VideoVo;
import com.tanhua.server.service.VideoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("/smallVideos")
public class VideoController {
    @Autowired
    private VideoService videoService;
    @PostMapping
    public ResponseEntity post(MultipartFile videoThumbnail,MultipartFile videoFile){
        videoService.post(videoThumbnail,videoFile);
        return ResponseEntity.ok(null);
    }
    @GetMapping
    public ResponseEntity getVideo(@RequestParam(value = "page",defaultValue = "1") Long page,@RequestParam(value = "pagesize",defaultValue = "10") Long pagesize){
       PageResult<VideoVo> pageResult= videoService.getVideo(page,pagesize);
        return ResponseEntity.ok(pageResult);
    }
    @PostMapping("/{smallVideoId}/userFocus")
    public ResponseEntity userFocus(@PathVariable Long smallVideoId){
      videoService.userFocus(smallVideoId);
        return ResponseEntity.ok(null);
    }
    @PostMapping("/{smallVideoId}/userUnFocus")
    public ResponseEntity userUnFocus(@PathVariable Long smallVideoId){
        videoService.userUnFocus(smallVideoId);
        return ResponseEntity.ok(null);
    }
}
